'use strict';
let Response = require('../../../model/Response');
let RestifyProxy = require('../../../util/RestifyProxy');
let CustomPageBean = require('../../../model/CustomPageBean');
let alarmService = require('../../../service/Alarm/alarmService');
let logger = require('../../../util/LoggerUtil').logger('alarmController.js');

/**
 * 告警管理页面
 */

module.exports.alarmPage = function () {
    let response = new Response();
    response.render('back/alarm/alarm');
    this.resolve(response);
};
/**
 * 账户列表
 */
module.exports.alarm_List = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await alarmService.getAlarmList(this, params);
        let pageBean = new CustomPageBean(result);
        response.send(pageBean);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
/**
 * 新增人工告警页面
 */

module.exports.createAlarmPage = function () {
    let response = new Response();
    response.render('back/alarm/create-alarm');
    this.resolve(response);
};
/**
 * 新增人工告警页面——zTree
 */
module.exports.getStorageTree= async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await alarmService.getStorageTreeList(this,params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
/**
 * 新增人工告警页面——确认按钮
 */
module.exports.alarmUpdate = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await alarmService.alarmUpdate(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
/**
 * 新增人工告警页面——回车搜索
 */
module.exports.searchEnter = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await alarmService.searchEnter(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
/**
 * 告警管理详情页面
 */

module.exports.alarmDetailPage = function () {
    let response = new Response();
    response.render('back/alarm/alarm-detail');
    this.resolve(response);
};
/**
 *告警详情页面——数据
 */
module.exports.getAlarmDetail= async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await alarmService.getAlarmDetail(this,params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};


